myApp.controller('expressDetailController',function($scope,toaster,$uibModal,$stateParams,$filter,$state,$log,$serOrder){
    var ctrl = this;
    ctrl.vm = {
        data:{},
        order_id:$stateParams.id,
        kuaiList:{},
        express_id:'',
        express_no:'',
        qty:'',
        product:[],
        shipments:function () {
            angular.forEach(ctrl.vm.data.not_delivered,function (data) {
                if(data.select){
                    ctrl.vm.product.push({'p_id':data.p_id,'attr_value_set':data.attr_value_set,'qty':data.qtys});
                }
            })
            $serOrder.delivery({
                order_id:ctrl.vm.order_id,
                express_id:ctrl.vm.express_id,
                express_no:ctrl.vm.express_no,
                product:ctrl.vm.product,
        }).then(function(res) {
                if(res.code == 1){
                    ctrl.vm.product = [];
                    vm.init();
                    vm.getEnableList();
                    toaster.info('提示',res.message);
                } else {
                    toaster.info('提示',res.message);
                }
            })
        }
    };
    var vm ={
        init:function(){
            $serOrder.getDelivery({
                id:$stateParams.id
            }).then(function(res){
                if(res.code==1){
                    ctrl.vm.data = res.data;
                }else{
                    toaster.info('提示',res.message);
                }
            })
        },
        getEnableList:function(){
            $serOrder.getEnableList({

            }).then(function(res){
                if(res.code==1){
                    ctrl.vm.kuaiList = res.data;
                }else{
                    toaster.info('提示',res.message);
                }
            })
        }
    };
    vm.init();
    vm.getEnableList();
});